package com.chuhe.common.exception;

import lombok.Data;

/**
 * @Author: 楚河
 * @Date: 2025年05月02日15:42
 */
@Data
public class BusinessException extends RuntimeException {
    protected Integer errorCode;
    protected String errorMsg;

    protected Integer code;

    protected String message;
    protected String info;
    /**
     * 其他适配
     * @Author: 楚河
     * @Date: 2025-05-12 21:45
     */
//    public BusinessException(String errorMsg){
//        super(errorMsg);
//        this.errorCode = CommonErrorEnum.BUSINESS_ERROR.getCode();
//        this.errorMsg = errorMsg;
//    }
//    public BusinessException(Integer errorCode, String errorMsg){
//        super(errorMsg);
//        this.errorCode = errorCode;
//        this.errorMsg = errorMsg;
//    }
//    public BusinessException(ErrorEnum errorEnum){
//        super(errorEnum.getErrorMsg());
//        this.errorCode = errorEnum.getErrorCode();
//        this.errorMsg = errorEnum.getErrorMsg();
//    }

    /**
     * 星空聊天室适配
     * @Author: 楚河
     * @Date: 2025-05-12 21:45
     */
    public BusinessException(String message, Throwable e) {
        super(message, e);
        this.message = message;
    }

    public BusinessException(String message) {
        super(message);
        this.info = message;
    }

    public BusinessException(CommonErrorEnum codeEnum) {
        super(codeEnum.getMsg());
        this.code = codeEnum.getCode();
        this.info = codeEnum.getMsg();
        this.message = codeEnum.getMsg();
    }

    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }
}
